<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<script type="text/javascript">
	
		// post 请求
	
		window.onload = function(){
			document.getElementsByTagName("a")[0].onclick = function(){
				var request = new XMLHttpRequest();
				// 在 url 后追加时间戳, 保证每次请求 url 不同, 可以防止浏览器缓存
				var url = this.href; 
				var method = "POST";
				
				request.open(method, url);
				request.send(null);
				
				request.onreadystatechange = function(){
					// 判断响应是否完成
					if(request.readyState == 4){
						// 判断响应是否可用
						if(request.status == 200 || request.status == 304){
							alert(request.responseText);
						}
					}
				}
				return false;
			}
		}
	</script>
  </head>
  
  <body>
    <h1><a href="../../../../../mine/ajaxtest/WebRoot/helloworld/helloAjax.txt">HelloAjax</a></h1>
  </body>
</html>
